package com.oreilly.ez.base;

import lombok.Data;
import lombok.ToString;

@Data
@ToString
public class R {

    private int code;
    private Object dat;
    private String tip = "";

    public static R ok(String tip) {

        R r = new R();
        r.setCode(0);
        r.setTip(tip);
        return r;
    }


    public static R ok(Object obj) {

        R r = new R();
        r.setCode(0);
        r.setDat(obj);
        return r;
    }

    public static R ok(Object obj, String tip) {

        R r = new R();
        r.setCode(0);
        r.setDat(obj);
        r.setTip(tip);
        return r;
    }

    public static R err(String tip) {

        R r = new R();
        r.setCode(-1);
        r.setTip(tip);
        return r;
    }
    public static R failed(int code, String tip) {

        R r = new R();
        r.setCode(code);
        r.setTip(tip);
        return r;
    }


}
